package dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface SoilMapper {
    /**
     * 通过城市名称查询
     * @param city 城市名称
     * @return 查询结果
     */
    // @Select("select count(*) from PMJLB,YPJLB where PMJLB.pmdh_N001 = YPJLB.sspmdh_N001 and txzwz_N000 like concat('%',#{city},'%')")
    @Select("select count(*) from sheet0,sheet1 where sheet0.`N001-剖面代号` = sheet1.`N001-所属剖面代号` and `N000-土系志位置` like concat('%',#{city},'%')")
    public List<Map<String, Object>> getDataByCityName(String city);

    /**
     * 通过经纬度查询
     * @param longitude 经度
     * @param latitude 纬度
     * @return 查询结果
     */
    // @Select("select * from PMJLB,YPJLB where PMJLB.pmdh_N001 = YPJLB.sspmdh_N001 and PMJLB.jd_N009 like concat(#{longitude},'%') and PMJLB.wd_N010 like concat(#{latitude},'%')")
    @Select("select * from sheet0,sheet1 where sheet0.`N001-剖面代号` = sheet1.`N001-所属剖面代号` and sheet0.`N009-经度` like concat(#{longitude},'%') and sheet0.`N010-纬度` like concat(#{latitude},'%')")
    public List<Map<String, Object>> getDataByCoordinate(@Param("longitude") String longitude, @Param("latitude") String latitude);

    /**
     * 通过城市名称查询采样点数量
     * @param city 城市名称
     * @return 采样点数量
     */
    @Select("select count(*) from sheet0 where `N000-土系志位置` like concat('%',#{city},'%')")
    public int countPointByCityName(String city);

    /**
     * 获取散点总数
     * @return 散点总数
     */
    @Select("select count(`N009-经度`) from sheet0")
    public int getNumberOfPoint();

    /**
     * 获取所有的散点经纬度
     * @return 所有散点的经纬度
     */
    @Select("select `N009-经度`,`N010-纬度` from sheet0")
    public List<Map<String, Object>> getAllPoint();
}
